package com.example.consumer;

import lombok.extern.log4j.Log4j2;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 消费者,只关注mail消息队列中，tag=red的消息
 */
@Log4j2
@Component
@RocketMQMessageListener(topic = "email", consumerGroup = "mail-consumer-group",selectorExpression = "red")
public class MailRedConsumer implements RocketMQListener<Message> {

    @Override
    public void onMessage(Message message) {
        String msg=new String(message.getBody());
        Map<String, String> properties = message.getProperties();

        log.info("mail-consumer-group收到消息：" + msg);
    }
}
